package com.wude.guild.holder;

import android.app.Activity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wude.bean.MyCouponBean;
import com.wude.guild.R;
import com.wude.tools.TimeUtil;

import org.xutils.x;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 描述：优惠券-已过期
 * 作者：闫冰
 * 时间: 2017-09-05 9:04
 */
public class CouponExpiredHolder extends BaseHolder<MyCouponBean.DataBean.OvertimeBean> {
    @BindView(R.id.tv_price)
    TextView tvPrice;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_hint)
    TextView tvHint;
    @BindView(R.id.tv_time)
    TextView tvTime;

    private Activity activity;
    private MyCouponBean.DataBean.OvertimeBean data;
    private final String TAG = "CouponExpiredHolder";

    @Override
    protected void refreshView(MyCouponBean.DataBean.OvertimeBean overtimeBean, int position, Activity activity) {
        this.activity = activity;
        this.data = overtimeBean;
        tvPrice.setText(overtimeBean.getValue());
        tvTitle.setText("《" + overtimeBean.getGame_name() + "》" + overtimeBean.getCoupon_class());
        if (overtimeBean.getIs_new().equals("1") && overtimeBean.getIs_newapp().equals("1")) {
            tvHint.setText("新注册用户可用，限新版本客户端可用");
        } else if (overtimeBean.getIs_new().equals("1")) {
            tvHint.setText("新注册用户可用");
        } else if (overtimeBean.getIs_newapp().equals("1")) {
            tvHint.setText("限新版本客户端可用");
        } else {
            tvHint.setText("无使用限制");
        }
        tvTime.setText("使用期限:" + TimeUtil.GetTime(overtimeBean.getUse_time_beg()) + " ~ " + TimeUtil.GetTime(overtimeBean.getUse_time_end()));
    }

    @Override
    protected View initView() {
        View inflate = LinearLayout.inflate(x.app(), R.layout.holder_coupon_expired, null);
        ButterKnife.bind(this, inflate);
        inflate.setTag(this);
        return inflate;
    }
}
